﻿using System;
using System.Collections.Generic;
using System.Text;

namespace designmodule.behavioralmodule.Observer
{
    public abstract class Observer
    {
        public abstract void Update();
    }

    public class ConcreteObserver: Observer
    {
        private string name;
        private string _observerState;
        private ConcreteSubject _subject;

        public ConcreteObserver(string name,
            ConcreteSubject subject)
        {
            this.name = name;
            _subject = subject;
        }

        public override void Update()
        {
            _observerState = _subject.subjectState;
            Console.WriteLine("观察者的新状态{0}",_observerState);
        }
    }
}
